package worldmap;

import java.util.HashMap;

import datatypes.XZasDouble;

public class WorldMap {
	
	//Long: XXXXZZZZ represents (XXXX, ZZZZ)
	HashMap<Long, MapColumn> worldmap = new HashMap<Long, MapColumn>();
		
	
	public MapColumn getColumn(int x, int z) {
		long coordinate = XZasDouble.toLong(x, z);
		
		loadColumn(x, z);
		return worldmap.get(coordinate);
	}
	
	
	
	/**
	 * Loads the requested column at (x,z) into memory.
	 * 
	 * @param x
	 * @param z
	 */
	private void loadColumn(int x, int z) {
		long coordinate = XZasDouble.toLong(x, z);
		
		//if the column was already loaded: don't do a thing!
		if(worldmap.containsKey(coordinate)) {
			return;
		}
		
		MapColumn column = new MapColumn();
		worldmap.put(coordinate, column);		
	}
	
	
}
